﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace Library.OrmEnterpriseEntity.TableInfo {
	///<summary>
	///</summary>
	public class ColumnViewCollection : IList<DbColumnView> {
		private readonly IList<DbColumnView> _columns;
		internal ColumnViewCollection() {
			_columns = new List<DbColumnView>();
		}
		internal ColumnViewCollection(IList<DbColumnView> columns) {
			_columns = columns;
		}

		public DbColumnView Find(string columnName) {
			return this.FirstOrDefault(column => column.ColumnName == columnName);
		}
		public DbColumnView Find(int index) {
			return _columns[index];
		}

		public IEnumerator<DbColumnView> GetEnumerator() {
			return _columns.GetEnumerator();
		}

		IEnumerator IEnumerable.GetEnumerator() {
			return GetEnumerator();
		}

		public virtual void Add(DbColumnView item) {
			_columns.Add(item);
		}

		public virtual void Clear() {
			throw new NotImplementedException();
		}

		public virtual bool Contains(DbColumnView item) {
			return _columns.Contains(item);
		}

		public virtual void CopyTo(DbColumnView[] array, int arrayIndex) {
			_columns.CopyTo(array, arrayIndex);
		}

		public virtual bool Remove(DbColumnView item) {
			throw new NotImplementedException();
		}

		public virtual int Count {
			get { return _columns.Count; }
		}

		public virtual bool IsReadOnly {
			get { return false; }
		}

		public virtual int IndexOf(DbColumnView item) {
			return _columns.IndexOf(item);
		}

		public virtual void Insert(int index, DbColumnView item) {
			throw new NotImplementedException();
		}

		public virtual void RemoveAt(int index) {
			throw new NotImplementedException();
		}

		public virtual DbColumnView this[int index] {
			get { return _columns[index]; }
			set { _columns[index] = value; }
		}
	}
}
